package com.news.gpb.service.impl;

import com.news.gpb.dao.BlogDao;
import com.news.gpb.entity.Blog;
import com.news.gpb.service.BlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("blogService")
public class BlogServiceImpl implements BlogService {

    @Autowired
    BlogDao blogDao;
    @Override
    public Integer writeBlog(Blog blog) {
        return blogDao.addBlog(blog);
    }

    @Override
    public List<Blog> getBlog(int user_id) {
        return blogDao.getBlog(user_id);
    }

    @Override
    public Integer countBlog(int user_id) {
        return blogDao.countBlog(user_id);
    }

    @Override
    public String deleteBlog(Blog blog) {
        Integer res = blogDao.deleteBlog(blog.getBlog_id());
        if(res!=null&&res!=0)
        {
            return "ok";
        }
        else return "error";
    }
}
